This article describes the operations that your code can invoke on the Sparkplug edge node object (an instance of the EasySparkplugEdgeNode Class), and the notifications that this object provides.
The Sparkplug edge node is started by calling the Start Method. The edge node must not already be started at that moment. This method initializes the edge node operations, sets up its contents, and initiates connection to the configured MQTT broker.
The Start Method operates asynchronously. The edge node may not yet be connected to the broker and ready for operation when this method completes.
After you call the Start Method, let the edge node run for as long as needed.
The Sparkplug edge node is stopped by calling the Stop Method. The edge node must be running (started) at that moment. This method stops the edge node operations and initiates disconnecting from the MQTT broker. This method performs a graceful shutdown of the edge node, ensuring that resources are properly released and that subscribers are notified of the disconnection.
The Stop Method operates asynchronously. The edge may not yet have disconnected from the MQTT broker when this method completes.
The following example illustrates how to start and stop the Sparkplug edge node.
The edge node object raises the Starting Event when the component is starting, and it raises the Stopped Event when the component has stopped.
These notifications are also broadcast to all metric and device objects, and can be handled on them too.
Example: Examples - Sparkplug Edge Node - React to starting and stopping
The edge node object implements the ISparkplugSystemConnectionMonitoring Interface, and provides notification about the state of its broker connection via the SystemConnectionStateChanged Event. For more information, see Rapid Toolkit for Sparkplug Operation Monitoring Services.
The example provided above for starting and stopping thre edge node (Examples - Sparkplug Edge Node - Start and stop the edge node, publish single metric) also illustrates how to receive notifications about system connection state changes.
Sparkplug is a trademark of Eclipse Foundation, Inc. "MQTT" is a trademark of the OASIS Open standards consortium. Other related terms are trademarks of their respective owners. Any use of these terms on this site is for descriptive purposes only and does not imply any sponsorship, endorsement or affiliation.